package com.winit.requirement.repository;

import com.winit.requirement.model.ReqFeature;
import com.winit.requirement.model.ReqFeatureId;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.util.List;
/**目前未使用 2018-01-10*/
public interface ReqFeatureRepository extends CrudRepository<ReqFeature, ReqFeatureId>{
    @Query(value = "SELECT * FROM matrix_req_feature_desc where req_id = ?1", nativeQuery = true)
    List<ReqFeature> findByReqId(String reqId);
    @Modifying
    @Transactional
    @Query(value = "update matrix_req_feature_desc set `desc` =  ?1 where req_id = ?2 and feature_id = ?3 ", nativeQuery = true)
    int updateReqFeatureDesc(String reqId, String featureId, String desc);

    @Modifying
    @Transactional
    @Query(value = "insert into matrix_req_feature_desc values(?1, ?2, ?3)", nativeQuery = true)
    void insertEntity(String reqId, String featureId, String desc);

    @Query(value = "select  * from matrix_req_feature_desc where req_id = ?1 and feature_id = ?2", nativeQuery = true)
    ReqFeature findByReqIdAndFeatureId(String reqId, String featureId);


    @Modifying
    @Transactional
    @Query(value = "DELETE FROM matrix_req_feature_desc where req_id = ?1 and feature_id = ?2", nativeQuery = true)
    void deleteById(String reqId, String featureId);


}
